//
//  LGMineHomeHeaderView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/10.
//

#import "LGMineHomeHeaderView.h"

@interface LGMineHomeHeaderView()
/**   */
@property (nonatomic , strong)UIImageView *headPic;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *groupLabel;
/**   */
@property (nonatomic , strong)UILabel *departeLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
/**   */
@property (nonatomic , strong)UILabel *serviceTitle;

@end

@implementation LGMineHomeHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.headPic];
        [self addSubview:self.nameLabel];
        [self addSubview:self.groupLabel];
        [self addSubview:self.departeLabel];
        [self addSubview:self.tipView];
        [self addSubview:self.serviceTitle];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headPic).offset(viewPix(8));
            make.left.equalTo(self.headPic.mas_right).offset(viewPix(12));
        }];
        [self.groupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel.mas_right).offset(viewPix(5));
            make.centerY.equalTo(self.nameLabel);
            make.width.equalTo(@(0));
            make.height.equalTo(@(viewPix(22)));
        }];
        [self.departeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nameLabel.mas_bottom).offset(viewPix(5));
            make.left.equalTo(self.nameLabel);
        }];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    //99:队长医生   10:专家医生  11:进修医生  40:康复医生  20:护士  30:个案管理师
    NSString *roleType = LGNSString(dataDic[@"role_type_val"]);
    UIImage *placeHolder = ([roleType isEqualToString:@"20"]||[roleType isEqualToString:@"30"])?defaultNursePic:defaultDoctorPic;
    [self.headPic sd_setImageWithURL:[NSURL URLWithString:dataDic[@"avatar_url"]] placeholderImage:placeHolder];
    self.nameLabel.text = dataDic[@"realname"];
    self.departeLabel.text = [NSString stringWithFormat:@"%@  %@",dataDic[@"department"],dataDic[@"profess"]];
    self.serviceTitle.text = ([roleType isEqualToString:@"20"]||[roleType isEqualToString:@"30"])?@"团队统计":@"服务统计";
}


-(UIImageView *)headPic{
    if(!_headPic){
        _headPic = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(4), statusBarHeight+24, viewPix(64), viewPix(64))];
        _headPic.backgroundColor = [UIColor colorWithString:@"#90C3FA"];
        _headPic.layer.borderColor = [UIColor colorWithString:@"#FFFFFF"].CGColor;
        _headPic.layer.borderWidth = 2.5;
        _headPic.cornerRidus = viewPix(32);
    }
    return _headPic;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _nameLabel.frame = CGRectMake(viewPix(80), kMinY(self.headPic.frame)+viewPix(8), viewPix(200), viewPix(25));
    }
    return _nameLabel;
}

-(UILabel *)groupLabel{
    if(!_groupLabel){
        _groupLabel = [UILabel lableWithText:@"" colorString:@"#56BEA0" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentCenter lines:1];
        _groupLabel.backgroundColor = [UIColor colorWithString:@"#EBF8F3"];
        _groupLabel.cornerRidus = viewPix(11);
    }
    return _groupLabel;
}

-(UILabel *)departeLabel{
    if(!_departeLabel){
        _departeLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _departeLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip16"]];
        _tipView.frame = CGRectMake(Screen_W-viewPix(40), kMinY(self.headPic.frame)+viewPix(24), viewPix(16), viewPix(16));
    }
    return _tipView;
}

-(UILabel *)serviceTitle{
    if(!_serviceTitle){
        _serviceTitle = [UILabel lableWithText:@"服务统计" colorString:@"#333333" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _serviceTitle.frame = CGRectMake(viewPix(8), kMaxY(self.headPic.frame)+viewPix(16), viewPix(150), viewPix(25));
    }
    return _serviceTitle;
}


@end
